@echo off
mkdir logs

set logfile=logs\view_%1_%db2_server_name%.sql

db2 -x select varchar(text,32670)  from syscat.routines where routinename=upper('%1') > %logfile%
echo ---------------------------------tables ---------------------------------- >> %logfile%
db2 -x select bname from syscat.packagedep where (btype='T' or btype='V') and pkgname in(select bname from sysibm.sysdependencies where dname =upper('%1')) >> %logfile%
start  %logfile%
